
import gexf
import gtfsdb
import graph_connector
import graph_hierarchy
import graph_coupling
import globalmap
from shortcuts import execute_sql, execute_select, log_info


def load_datasets():
    dataset_list = {}
    results = execute_select("SELECT dataset_name, dataset_id FROM gtfs_dataset")
    for dataset_name, dataset_id in results:
        dataset_list[dataset_name] = dataset_id
    return dataset_list


if __name__ == '__main__':
    
    dataset_list = ["nyctrs", "nycbus", "njtrs", "nynjpa", "mtrnth", "lirail", "libus"]
    #dataset_list = ["nyctrs", "njtrs", "nynjpa", "mtrnth", "lirail"]
    #dataset_list = ["nycbus", "libus"]
    
    #dataset_list = ["lonund", "londlr", "lonbus", "lontam"]
    
    #dataset_list = ["se"]
    
    gtfsdb.build_union(dataset_list)
    
    execute_sql("DELETE FROM global_graph")
    
    for dataset_name in dataset_list:
        globalmap.update_node_tiles(dataset_name)
        graph_hierarchy.local_hierarchy(dataset_name)
    
    graph_hierarchy.global_hierarchy(dataset_list)
    
    """ TODO: if global_graph has a network not in the list below, there will be problem """
    gexf.output_highway_graph(dataset_list, "graph")

